<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %>
<%@ include file="/home/include/init_home.jsp" %>
<%
	String board_id			= StringUtil.nvl(request.getParameter("board_id"));
	String search_col		= StringUtil.nvl(request.getParameter("search_col"), "subject");
	String search_word		= StringUtil.toHan(StringUtil.nvl(request.getParameter("search_word")));
	String curr_page 		= StringUtil.nvl(request.getParameter("curr_page"), "1");


	String search_url		= "./boardList.jsp?board_id="+board_id+"&pmenu_id="+pmenu_id+"&menu_id="+menu_id+"&search_col="+search_col+"&search_word="+search_word;

	HashMap infos = new HashMap();
	infos.put("board_id",		board_id);
	infos.put("search_col",		search_col);
	infos.put("search_word",	search_word);
	infos.put("curr_page",		curr_page);

	BoardDAO boardDAO 		= new BoardDAO();
	HashList boardList		= boardDAO.selectBoardList(infos);
	HashList wordList 		= boardDAO.selectWordList(infos);

	int totalCount 			= boardDAO.selectWordCount(infos);
	int totalPage			= boardDAO.getTotalPage(totalCount);

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><%= HOME_NAME %></title>
<style type="text/css">
</style>
<link href="../css/home.css" rel="stylesheet" type="text/css">
</head>

<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <%@ include file="/home/include/top_menu.jsp" %>
  <tr>
    <td valign="top" align="center" class="sub_con"><table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
      <!--좌측네비 시작-->
        <%@ include file="/home/include/left_menu.jsp" %>
        <!--좌측네비 끝-->
        <td width="50"></td>
        <!--컨텐츠 시작-->
        <td valign="top" align="left"><table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td><img src="../images/sub/<%=pmenu_id %>_title_01.gif" height="31" /><img src="../images/sub/<%=pmenu_id %>_title_sub.gif"  /></td>
                <td align="right" valign="bottom"></td>
              </tr>
            </table></td>
          </tr>
          <tr>
            <td height="5"><img src="../images/sub/sub_line.gif" width="723" height="5" /></td>
          </tr>
          <tr>
            <td height="30"></td>
          </tr>
          <tr>
            <td class="sub_title"><%= menu_name %></td>
          </tr>
          <tr>
            <td height="40"></td>
          </tr>
          <tr>
            <td align="right" style="padding-right:40px;">
            <form name="searchForm" action="./boardList.jsp">
            <input type="hidden" name="board_id" value="<%= board_id %>"/>
            <input type="hidden" name="pmenu_id" value="<%= pmenu_id %>"/>
            <input type="hidden" name="menu_id" value="<%= menu_id %>"/>

            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td align="right">
                <select name="search_col"  size="1" style="width:80px;">
                  <option value="subject" <%= StringUtil.selected("subject", search_col) %>>제목</option>
                  <option value="content" <%= StringUtil.selected("content", search_word) %>>내용</option>
                  <option value="author_name" <%= StringUtil.selected("author_name", search_word) %>>글쓴이</option>
                </select></td>
                <td width="4"></td>
                <td width="100"><input type="text" name="search_word" size="5" style="width:146px;" value="<%= search_word %>" class="input2" /></td>
                <td width="4"></td>
                <td width="35">
                	<input type="image" src="../images/sub/expand.gif" alt="찾기" width="35" height="22" />
                </td>
              </tr>
            </table>
            </form>
            </td>
          </tr>
          <tr>
          	<td height="18"></td>
            </tr>
            <tr>
            <td><table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td colspan="4" height="2" bgcolor="#999999"></td>
              </tr>
              <tr height="32">
                <th width="80" align="center">번호</th>
                <th width="420" align="center">제목</th>
                <th width="100" align="center">글쓴이</th>
                <th width="100" align="center">날짜</th>
              </tr>
              <tr>
                <td colspan="4" height="1" bgcolor="#cccccc"></td>
              </tr>
              <tr>
                <td colspan="4"><table width="700" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
       <%
         String prevWordNum = "";
         for (int i = 0; i < wordList.size(); i++) {

       %>
                      <tr>
                        <td width="80" height="34" align="center" valign="middle">
                        <%			if (prevWordNum.equals(wordList.get("word_num",i))) {	%>
										&nbsp;
						<%			} else {	%>
										<%= wordList.get("word_num",i) %>
						<%			}	%>
                        </td>
                        <td valign="middle" class="board_txt">
<%			if (!"0".equals(wordList.get("depth",i)))
		 	{
%>			 		<span style="width:<%= 20 * (wordList.getInt("depth",i)-1) %>">&nbsp;</span>
					<img src="/img/icon/ico_re_i.gif">
<%			}	%>


                        <a href="./boardView.jsp?word_id=<%=wordList.get("word_id",i) %>&board_id=<%=board_id %>&pmenu_id=<%=pmenu_id%>&menu_id=<%=menu_id%>&search_col=<%=search_col%>&search_word=<%=search_word%>&curr_page=<%=curr_page%>"><%= StringUtil.substring(wordList.get("subject",i),32) %></a>
                        <% 	if ("Y".equals(wordList.get("new_yn",i))) { %>
								<img src="/images/icon/ico_new.gif" style="vertical-align:middle"/>
						<%	} %>
						<% 	if ("Y".equals(wordList.get("hit_yn",i))) { %>
								<img src="/images/icon/ico_hot.gif" style="vertical-align:middle"/>
						<%	} %>

                        </td>
                        <td width="100" align="center" valign="middle"><%= wordList.get("author_name",i) %></td>
                        <td width="100" align="center" valign="middle"><%= wordList.get("init_date",i) %></td>
                      </tr>
                      <tr>
                        <td height="1" colspan="4" class="board_line"></td>
                      </tr>
   <%
       	prevWordNum = wordList.get("word_num",i);
         } %>
                    </table></td>
                  </tr>
                </table></td>
              </tr>
              <tr>
                <td height="20"></td>
              </tr>
              <tr>
                <td colspan="4" align="right" style="padding-right:20px">
		<%	if ("Y".equals(boardList.get("admin_yn", 0))) {
				if (!"".equals(session_dept_code)) {	%>
					<a href="./boardWrite.jsp?board_id=<%= board_id %>&pmenu_id=<%=pmenu_id%>&menu_id=<%=menu_id%>"><img src="../images/sub/write02.gif" /></a>
		<%		}
			} else {	%>
					<a href="./boardWrite.jsp?board_id=<%= board_id %>&pmenu_id=<%=pmenu_id%>&menu_id=<%=menu_id%>"><img src="../images/sub/write02.gif" /></a>
		<%	}	%>
				</td>
              </tr>

            </table>
             <table width="100%" border="0" cellspacing="0" cellpadding="0">
		  <tr>
			<%= StringUtil.getPageMove(totalPage, Integer.parseInt(curr_page), search_url) %>
		  </tr>
		</table>

		</td>
          </tr>
          <tr>
          	<td height="80"></td>
          </tr>
        </table></td>
        <!--컨텐츠 끝-->
      </tr>
    </table></td>
  </tr>
  <%@ include file="/home/include/footer.jsp" %>
</table>
</body>
</html>
